package com;

import javax.swing.*;

public class Pig extends ActivityObject {
    private ImageIcon image;
    private int imageNum = 0;//控制死亡动画帧率

    public static Pig getPig1(int x,int y){
        Pig pig = new Pig(x,y);
        pig.image = Images.pig1;
        return pig;
    }
    public static Pig getPig2(int x,int y){
        Pig pig = new Pig(x,y);
        pig.image = Images.pig2;
        return pig;
    }

    public Pig(int x,int y){
        super(x,y,23);
    }

    public ImageIcon getImage() {
        if(state==GO_DEAD){
            int index = imageNum/4;
            if(index==Images.bongs.length){
                state = DEAD;
                image = Images.bongs[Images.bongs.length-1];
            }else {
                imageNum++;
                return Images.bongs[index];
            }
        }
        return image;
    }

}
